﻿@model Retete.ViewModels.ReteteDeleteViewModel
@{
    ViewBag.Title = "Retete";
}

<script type="text/javascript">
    function stergeInregistrare(id) {
        if (confirm("Doriti sa stergeti reteta selectata?") == true) {
            IDRetetaStearsa.value = id;
            form.submit();
        }
    }
    function salveazaPreturi() {
        SalveazaPreturi.value = true;
        form.submit();
    }
</script>

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "form", name = "form" }))
{
    for (int i = 0; i < Model.Categorii.Count; i++)
    {
        @Html.HiddenFor(element => element.Categorii[i])
    }
    
    <table style="width: 100%">
        <tr>
            <td style="width: 190px; vertical-align: top; border-right-style: dashed; border-right-color: #CFCFCF; border-right-width: 1px;">
                <fieldset>
                    <legend>Activitati</legend>

                    <p class="toolbox">@Html.ActionLink("Adauga reteta", "Create")</p>
                    <p class="toolbox"><a href="javascript:salveazaPreturi()">Salveaza modificari de preturi</a></p>
                </fieldset>
            </td>
            <td style="vertical-align: top;">
                @Html.ValidationSummary(false)
                @Html.HiddenFor(model => model.IDRetetaStearsa)
                @Html.HiddenFor(model => model.SalveazaPreturi)

                <fieldset>
                    <legend>Cautare reteta</legend>

                    <p>
                        @Html.LabelFor(element => element.FiltruCategorie, "Categorie:")
                        @Html.DropDownListFor(element => element.FiltruCategorie, new SelectList(Model.Categorii), new { style = "width: 196px" })
                    </p>

                    <p>
                        @Html.LabelFor(element => element.FiltruNume, "Nume:")
                        @Html.TextBoxFor(element => element.FiltruNume, new { style = "width: 190px" })
                    </p>

                    <p>
                        @Html.LabelFor(element => element.FiltruNume, " ")
                        <a href="javascript:form.submit()">Filtreaza</a>
                    </p>
                </fieldset>

                <fieldset>
                    <legend>Lista retetelor filtrate</legend>

                    <table class="grid">
                        <thead>
                            <tr>
                                <th style="width: 16px"></th>
                                <th style="width: 70px">Cod</th>
                                <th style="width: 150px">Categorie</th>
                                <th>Reteta</th>
                                <th>Cantitate</th>
                                <th style="width: 139px;">Pret</th>
                            </tr>
                        </thead>

                        @for (int i = 0; i < Model.Retete.Count; i++)
                        {
                            <tr>
                                <td>
                                    <img src="@Url.Content("~/Content/Images/Delete.png")" alt="Sterge" style="height: 12px; cursor: pointer;" onclick="stergeInregistrare(@Model.Retete[i].ID)" />
                                    @Html.HiddenFor(element => element.Retete[i].ID)
                                </td>
                                <td>
                                    @Model.Retete[i].Cod
                                    @Html.HiddenFor(element => element.Retete[i].Cod)
                                </td>
                                <td>
                                    @Model.Retete[i].Categorie
                                    @Html.HiddenFor(element => element.Retete[i].Categorie)
                                </td>
                                <td>
                                    @Html.ActionLink(Model.Retete[i].Nume, "Edit", new { id = Model.Retete[i].ID })
                                    @Html.HiddenFor(element => element.Retete[i].Nume)
                                </td>
                                <td>
                                    @Model.Retete[i].Cantitate
                                    @Html.HiddenFor(element => element.Retete[i].Cantitate)
                                </td>
                                <td class="insertionCell">@Html.TextBoxFor(element => element.Retete[i].Pret)</td>
                            </tr>
                        }
                    </table>
                </fieldset>
            </td>
        </tr>
    </table>
}